<?php 
## include required files
/*******************************/
require_once '../model/sitesettings.php';
/*******************************/
## Create Objects
/*******************************/
$settingObj = new Model_Sitesettings();
/*******************************/
if(isset($_POST['add_txt'])) {
	## apply PHP validation for required filed
	if(trim($_POST['setting_value']) != '' ) {
			
			$array = array();
			$array['setting_value'] = return_post_value($_POST['setting_value']);
			$settingObj->editSettingVlaueById($array, base64_decode($_GET['id']));
			$_SESSION['msg'] = "<div class='success_msg'><span>Config value updated successfully. </span></div>";
			header('location:'.SITE_URL.'/admin/home.php?q=sitesettings');
			exit;
			
	} else {// php validation else
		$_SESSION['msg'] = "<div class='error_msg'><span>Please setting value.</span></div>";
	}
	// main if closed
}

## Assign success or error msg to smarty variable and unset session variable
if(trim($_SESSION['msg']) != '') {
	$smarty->assign('msg', $_SESSION['msg']);
	unset($_SESSION['msg']);
}

## Fetch footer text
if(isset($_GET['id'])) {
	$id = base64_decode($_GET['id']);
	$settings = $settingObj->getSettingValueById($id);
	$smarty->assign('settings', $settings);
}

## Set active class variable for left menu (main menu and sub menu)
$smarty->assign('activeclass', 'sitesettings');
$smarty->assign('mainmenu', '4');

## Unset all the objects created which are on this page
unset($settingObj);

$smarty->display(TEMPLATEDIR_ADMIN. 'settings/updatesitesetting.tpl');
unset($smarty);
?>